//用于对API统一管理
import request from "./request";
import mockRequest from "./mockAjax"
//三级联动接口
//请求地址：api/product/getBaseCategoryList 方法GET 无参数
//发请求: axios发请求返回结果式Promise对象
export const reqCategoryList = () => request({ url: '/product/getBaseCategoryList', method: 'get' });

//获取banner（home首页轮播图）
export const reqBannerList = () => mockRequest.get('/banner');
//获取floor数据
export const reqFloorList = () => mockRequest.get('/floor');
//获取搜索模块的数据 地址：/api/list 请求方式：post 参数：需要带参数
/*
{
    "category3Id": "61",
    "categoryName": "手机",
    "keyword": "小米",
    "order": "1:desc",
    "pageNo": 1,
    "pageSize": 10,
    "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
    "trademark": "4:小米"
}
*/
//当前函数需要接受外部传递参数
//获取搜索结果
export const reqGetSearchInfo = (params) => request({ url: '/list', method: 'post', data: params });
//获取商品详细信息
export const reqGoodsInfo = (skuid) => request({ url: `/item/${skuid}`, method: 'get' });
//添加购物车，或者更新某一产品的个数
// /api/cart/addToCart/{skuId}/{skuNum}
export const reqAddOrUpdateShopCart = (skuid, skuNum) => request({ url: `/cart/addToCart/${skuid}/${skuNum}`, method: 'post' });
//获取购物车列表数据
export const reqCartList = () => request({ url: '/cart/cartList', method: 'get' });
//删除购物车的数据
export const reqDeleteCartId = (skuId) => request({ url: `/cart/deleteCart/${skuId}`, method: 'delete' });
//修改购物车中选中状态
export const reqChangeCheckById = (skuId, isChecked) => request({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' });
//获取验证码
// /api/user/passport/sendCode/{phone}
export const reqGetCode = (phone) => request({ url: `/user/passport/sendCode/${phone}`, method: 'get' });
//注册账号
export const reqUserRegister = (data) => request({ url: '/user/passport/register', method: 'post', data });
//登陆账号
export const reqUserLogin = (data) => request({ url: '/user/passport/login', method: 'post', data });
//获取用户信息[需要带着用户的token向服务器要用户信息]
export const reqUserInfo = () => request({ url: '/user/passport/auth/getUserInfo', method: 'get' });
//退出登陆
export const reqLogout = () => request({ url: '/user/passport/logout', method: 'get' });
//获取用户地址信息
export const reqAddressInfo = () => request({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' });
//获取商品清单
export const reqOrderInfo = () => request({ url: '/order/auth/trade', method: 'get' });
//提交订单的接口
export const reqSubmitOrder = (tradeNo, data) => request({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, method: 'post', data });
//获取订单信息
export const reqPayInfo = (orderId) => request({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' });
//获取订单支付状态
export const reqPayStatus = (orderId) => request({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' });
//获取个人中心数据
export const reqMyOrderList = (page, limit) => request({ url: `/order/auth/${page}/${limit}`, method: 'get' })